<template>
  <div>
    <!-- 导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/constanttype' }">常数类型管理</el-breadcrumb-item>
      <el-breadcrumb-item>常数项目管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-button type="text" @click="add">添加数据</el-button>
    <!--Constantitem表单详情-->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed prop="id" label="id"></el-table-column>
      <el-table-column prop="constanttypeid" label="所属常数类别ID"></el-table-column>
      <el-table-column prop="constantcode" label="常数项编码"></el-table-column>
      <el-table-column prop="constantname" label="常数项名称"></el-table-column>
      <el-table-column prop="delmark" label="DelMark"></el-table-column>

      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="edit(scope.row)" type="text" size="small">修改</el-button>
          <el-button @click="deleteconstantitem(scope.row)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页条 -->
    <!-- <div class="block" style="margin-top:1rem;margin-left:20%">
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="pageInfo.total" :current-page="pageInfo.pageNum" :page-sizes="[8,16,32,50,100]" :page-size="pageInfo.pageSize" layout=" prev, pager, next, jumper,total, sizes">
        </el-pagination>
    </div>-->
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        {
          id: "",
          constanttypeid: "",
          constantcode: "",
          constantname: "",
          delmark: "1",
        },
      ],
      // 页面信息
      pageInfo: {
        pageNum: 1,
        pageSize: 8,
        total: 0,
      },
    };
  },
  methods: {
    edit(row) {
      // console.log(row.id);
      this.$router.push({
        path: "/updateconstantitem",
        query: {
          id: row.id,
        },
      });
    },
    deleteconstantitem(row) {
      this.$http
        .get(
          "http://localhost:8085/his/constantitem/deleteById/" +
            row.id
        )
        .then(function (resp) {});
      window.location.reload();
    },
    add(row) {
      this.$router.push({
        path: "/addconstantitem",
      });
    },
    //分页函数 查询条数改变
    handleSizeChange(size) {
      this.pageInfo.pageNum = 1;
      this.pageInfo.pageSize = size;
      this.searchUserList();
    },
    //分页函数 查询页数改变
    handleCurrentChange(page) {
      this.pageInfo.pageNum = page;
      this.searchUserList();
    },
    // async listConstantitem() {
    //     const {
    //         data: res
    //     } = await this.$http.post('/constantitem/listConstantitem', {
    //         id: this.tableData.id,
    //         constanttypeid: this.tableData.constanttypeid,
    //         constantcode: this.tableData.constantcode,
    //         constantname: this.tableData.constantname,
    //         delmark: this.tableData.delmark,
    //         pageNum: this.pageInfo.pageNum,
    //         pageSize: this.pageInfo.pageSize
    //     });
    //     if (res.meta.status !== 200) {
    //         return this.$message.error('获取用户列表失败')
    //     }
    //     this.tableData = res.info.list
    //     this.pageInfo.pageNum = res.info.pageNum
    //     this.pageInfo.pageSize = res.info.pageSize
    //     this.pageInfo.total = res.info.total
    //     console.log(res);
    //     // console.log(this.UserData)

    // }
  },

  created() {
    const _this = this;
    //alert(this.$route.query.id)
    this.$http
      .get(
        "http://localhost:8085/his/constantitem/findShow/" +
          this.$route.query.id
      )
      .then(function (resp) {
        console.log(resp)
        _this.tableData = resp.data;
      });
    //this.listConstantitem();
  },
};
</script>

<style scoped>
</style>
